import { IFeidaoAiMobile } from '@dfeidao/atom-mobile/interfaces';
import set from '@dfeidao/atom-mobile/local/set';
import nodejs from '@dfeidao/atom-mobile/msg/nodejs';
import render from '@dfeidao/atom-mobile/render/render';
import whoami from '../atom/whoami_getparams';
export default async function a002(fd: IFeidaoAiMobile) {
	// 初始化触发未审批
	// 获取系统参数,未登录，获取不到session报错
	const user = await whoami(fd) as {
		params: {
			teacher_name: string;
			productid: string;
			teacher_no: string;
		}
	};
	await set(fd, 'user_who', user);

	const d = await nodejs<[]>('app-parental-leave/s002', {
		filter: {
			teacher_no: user.params.teacher_no,// teacher_noJS0004 todo ps.params.teacher_no
			auditor_status: ['0'],
			productid: user.params.productid
		},
		page_size: 10,
		page_on: 1
	});

	await set(fd, 'page', 1);
	await set(fd, 'auditor_status', ['0']);
	await set(fd, 'data', d);
	render(fd, {
		d: d.map((item: {}, i) => {
			return { ...item, index: i };
		}), t: 'topText', t1: 'topText2', len: d.length
	});
}
